//
//  ST_AIRecommendHelpItemView.swift
//  btvideo
//
//  Created by mac on 2020/7/6.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit

class ST_AIRecommendHelpItemView: UIControl {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = .white
        self.cornerRadius = 10
        self.addSubview(cover_image_view)
        cover_image_view.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        cover_image_view.addSubview(coverMask)
        coverMask.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        coverMask.addSubview(cover_selected_mask)
        cover_selected_mask.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.height.equalTo(24)
        }
        
        self.addSubview(textLabel)
        textLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(8)
            make.bottom.equalToSuperview().offset(-8)
            make.height.equalTo(textLabel.font.lineHeight + 6)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override var isSelected: Bool{
        didSet{
            coverMask.isHidden = !isSelected
        }
    }
    
    fileprivate lazy var coverMask:UIView = {
        let control = UIView()
        control.backgroundColor = UIColor.init(white: 0, alpha: 0.4)
        control.isHidden = true
        return control
    }()
    
    fileprivate lazy var cover_selected_mask:UIImageView = {
        let control = UIImageView()
        control.image = ST_ImageUtils.imageName("个人中心_icon_选择sel")
        return control
    }()
    
    
  fileprivate lazy var cover_image_view:UIImageView = {
    let control = UIImageView()
        return control
    }()
    
    fileprivate lazy var textLabel:UILabel = {
        let control = UILabel.init()
        control.text = ""
        control.textColor = UIColor.white
        control.font = UIFont.systemFont(ofSize: 14/375.0*ScreenWidth, weight: UIFont.Weight.medium)
        return control
    }()

    var model:ST_AIRecommendHelpItemViewModel?{
        didSet{
            guard let m = model else{return}
            textLabel.text = m.title
            cover_image_view.image = UIImage.init(named: m.imageName)
        }
    }
    
//    
}


struct ST_AIRecommendHelpItemViewModel {
    var imageName:String
    var title:String
}
